builder-tool: Check canonical names
authorMatthias Clasen <mclasen@redhat.com>
Tue, 23 Apr 2019 21:30:00 +0000 (17:30 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 23 Apr 2019 21:30:00 +0000 (17:30 -0400)
Always canonicalize names before comparing.
We were missing properties like left_attach,
since we were comparing them to left-attach.

gtk/tools/gtk-builder-tool-simplify.c

index 9b7eeeba14ba3ed0c63ab7b824efd83c99f30d3c..4ef7373bd3859e39bc0aabffadfabb397fd56ec8 100644 (file)
@@ -189,7 +189,7 @@ needs_explicit_setting (GParamSpec *pspec,
 
 static gboolean
 keep_for_rewrite (const char *class_name,
-                  const char *prop_name,
+                  const char *property_name,
                   PropKind kind)
 {
   struct _Prop {
@@ -213,12 +213,16 @@ keep_for_rewrite (const char *class_name,
   };
   gboolean found;
   gint k;
+  char *canonical_name;
+
+  canonical_name = g_strdup (property_name);
+  g_strdelimit (canonical_name, "_", '-');
 
   found = FALSE;
   for (k = 0; k < G_N_ELEMENTS (props); k++)
     {
       if (strcmp (class_name, props[k].class) == 0 &&
-          strcmp (prop_name, props[k].property) == 0 &&
+          strcmp (canonical_name, props[k].property) == 0 &&
           kind == props[k].kind)
         {
           found = TRUE;
@@ -226,6 +230,8 @@ keep_for_rewrite (const char *class_name,
         }
     }
 
+  g_free (canonical_name);
+
   return found;
 }